#ifndef __WIZ_BNF_PARSER_SIGN_HPP__SHANHAOBO_19800429__
#define __WIZ_BNF_PARSER_SIGN_HPP__SHANHAOBO_19800429__

#include "./WizBNFParser.hpp"

namespace Wiz
{
    namespace BNF
    {
        namespace Parser
        {
            namespace Sign
            {
                //////////////////////////////////////////////////////////////////////////
                template <typename ScannerT>
                ::Wiz::Bool::Type DoParse(::Wiz::Size::Out OutCnt, ScannerT const& Scan)
                {
                    //  Extract the sign
                    OutCnt = 0;
                    ::Wiz::Bool::Type IsNeg = *Scan == '-';
                    if (IsNeg || (*Scan == '+'))
                    {
                        ++Scan;
                        ++OutCnt;
                        return IsNeg;
                    }

                    return ::Wiz::Bool::False;
                }
                //////////////////////////////////////////////////////////////////////////
            } /// end of namespace Sign

            namespace Sign
            {
                struct Type : public ::Wiz::BNF::Parser::Type<Type>
                {
                    typedef Type tThis;

                    template <typename ScannerT>
                    struct Result
                    {
                        typedef typename ::Wiz::BNF::Match::Result<
                            ScannerT,
                            ::Wiz::Bool::Type
                        >::tType tType;
                    };

                    Type(){}

                    template <typename ScannerT>
                    typename ::Wiz::BNF::Parser::Result<tThis, ScannerT>::tType
                    ParseImpl(ScannerT const& Scan) const
                    {
                        typedef typename ScannerT::tIterator                        tIterator;

                        if (Scan.AtEnd() == ::Wiz::Bool::False)
                        {
                            ::Wiz::Size::Type Len;
                            tIterator StartItr(Scan.m_Curr);
                            ::Wiz::Bool::Type IsNeg = ::Wiz::BNF::Parser::Sign::DoParse(Len, Scan);
                            if (Len > 0)
                            {
                                return Scan.CreateMatch(1, IsNeg, StartItr, Scan.m_Curr);
                            }
                        }
                        return Scan.NoMatch();
                    }
                }; /// end of struct Type
            } /// end of namespace Sign
            namespace Predef
            {
                namespace Sign
                {
                    const ::Wiz::BNF::Parser::Sign::Type Check = ::Wiz::BNF::Parser::Sign::Type();
                } /// end of namespace Sign
            } /// end of namespace Predef
        } /// end of namespace Parser
    } /// end of namespace BNF
} /// end of namespace Wiz

#endif /*__WIZ_BNF_PARSER_SIGN_HPP__SHANHAOBO_19800429__*/
